package org.zb.main;

import org.newdawn.slick.BasicGame;
import org.newdawn.slick.Color;
import org.newdawn.slick.Game;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.zb.controller.GameController;
import org.zb.controller.ObjectController;
import org.zb.object.Enemy;
import org.zb.object.MovingObject;
import org.zb.object.Player;
import org.zb.world.Scene;

public class TestGame extends BasicGame {

	ObjectController objectController = GameController.objectController;
	Scene scene = GameController.scene;
	
	public TestGame(String title) {
		super(title);
	}

	@Override
	public void render(GameContainer container, Graphics g) throws SlickException {
		g.setBackground(Color.black);
		scene.render(container, g, -GameController.getOffsetX(), -GameController.getOffsetY());
		objectController.render(container, g);
	}

	@Override
	public void init(GameContainer container) throws SlickException {
		for(int i=0;i<3;i++) {
			for(int j=0;j<3;j++) {
				MovingObject o = new Enemy();
				o.position.x = i * 200;
				o.position.y = j * 200;
				objectController.objects.add(o);
			}
		}
		objectController.player.position.set(400,300);
		
		objectController.init(container);
		scene.init(container);
	}

	@Override
	public void update(GameContainer container, int delta) throws SlickException {
		objectController.update(container, delta);
		
		GameController.viewport.setCenterX(objectController.player.position.x);
		GameController.viewport.setCenterY(objectController.player.position.y);
	}

}
